package 代码记录.指定公司代码练习记录.华为_2024.分值100;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * @author zx
 * @create 2024-01-31 14:50
 */
public class 字符串统计_12 {
    /**
     * 之前自己做过的思路
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] temp = str.split("@");
        String prev = temp[0];
        String end = temp[1];
        String[] arr1 = prev.split(",");
        //使用有序集合保证题目要求的顺序
        LinkedHashMap<String,Integer> map = new LinkedHashMap<>();
        for(int i = 0;i < arr1.length;i++){
            String[] num1 = arr1[i].split(":");
            map.put(num1[0],Integer.parseInt(num1[1]));
        }
        String[] arr2 = end.split(",");
        for(int i = 0;i < arr2.length;i++){
            String[] num2 = arr2[i].split(":");
            if(map.containsKey(num2[0])){
                map.put(num2[0],map.get(num2[0]) - Integer.parseInt(num2[1]));
            }
            if(map.get(num2[0]) == 0){
                map.remove(num2[0]);
            }
        }
        int size = map.size();
        int count = 0;
        for(Map.Entry<String,Integer> entry : map.entrySet()){
            if(count != size - 1){
                System.out.print(entry.getKey() + ":" + entry.getValue() + ",");
            }else{
                System.out.print(entry.getKey() + ":" + entry.getValue());
            }
            count++;
        }
    }
}
